<template>
  <div class="topic-list-container" style="margin: 0 1em;">
    <h1 class="topic-list-title">话题列表</h1>
    <ul class="topic-list">
      <li v-for="(item, index) in topicList" :key="index" class="topic-item">
        <div class="topic-wrap">
          <div class="topic-thumb">
            <img :src="item.imgUrl" alt="" />
          </div>
          <div class="topic-info">
            <h2 class="topic-title">{{ item.title }}</h2>
            <div class="topic-meta">
              <span class="topic-views">
                <i class="fas fa-eye"></i>
                {{ item.views }}
              </span>
              <span class="topic-comments">
                <i class="fas fa-comment-alt"></i>
                {{ item.comments }}
              </span>
              <span class="topic-time">
                <i class="far fa-clock"></i>
                {{ item.time }}
              </span>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  name: 'Qa',
  setup() {
    const topicList = ref([
      {
        title: '作为 IT 行业的过来人，你有什么话想对后辈说的？',
        views: 1000,
        comments: 20,
        time: '2022-12-05 09:00',
        imgUrl: 'https://pic1.zhimg.com/80/v2-8e77b2771314f674cccba5581560d333_xl.jpg?source=4e949a73'
      },
      {
        title: '作为 IT 行业的过来人，你有什么话想对后辈说的？',
        views: 500,
        comments: 10,
        time: '2022-12-05 09:00',
        imgUrl: 'https://pic1.zhimg.com/80/v2-8e77b2771314f674cccba5581560d333_xl.jpg?source=4e949a73'
      },
      {
        title: '作为 IT 行业的过来人，你有什么话想对后辈说的？',
        views: 2000,
        comments: 30,
        time: '2022-12-05 09:00',
        imgUrl: 'https://pic1.zhimg.com/80/v2-8e77b2771314f674cccba5581560d333_xl.jpg?source=4e949a73'
      }
    ])
    return {
      topicList
    }
  }
}
</script>

<style scoped>
.topic-list-container {
  max-width: 800px;
  margin: 0 auto;
}

.topic-list-title {
  font-size: 24px;
  text-align: center;
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.topic-item {
  margin-bottom: 20px;
}

.topic-wrap {
  display: flex;
  align-items: center;
  background-color: #f8f8f8;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: background-color 0.2s;
}

.topic-wrap:hover {
  background-color: #e6e6e6;
}

.topic-thumb {
  width: 40%;
  height: 0;
  padding-bottom: 28%;
  position: relative;
}

.topic-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-info {
  flex: 1;
  padding: 10px;
}

.topic-title {
  font-size: 18px;
  margin: 0;
  margin-bottom: 5px;
}

.topic-meta {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.topic-meta span {
  margin-right: 10px;
}

.topic-meta i {
  margin-right: 5px;
  color: #888;
}
</style>